Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
markdownlint-rule-helpers
Advanced tools
A collection of markdownlint helper functions for custom rules
The markdownlint-rule-helpers package provides utility functions to assist in writing custom rules for markdownlint, a popular Markdown linter. These helpers simplify common tasks such as parsing Markdown content, managing tokens, and handling rule options.
parseMarkdown
The parseMarkdown function takes a string of Markdown content and returns a parsed representation of it, which can be used for further analysis or rule enforcement.
const { parseMarkdown } = require('markdownlint-rule-helpers');
const markdownContent = '# Title\n\nSome content';
const parsed = parseMarkdown(markdownContent);
console.log(parsed);
getLineMetadata
The getLineMetadata function processes an array of lines from a Markdown document and returns metadata about each line, such as its length and whether it is blank. This is useful for rules that need to analyze line-by-line content.
const { getLineMetadata } = require('markdownlint-rule-helpers');
const lines = ['# Title', '', 'Some content'];
const metadata = getLineMetadata(lines);
console.log(metadata);
addError
The addError function helps in adding error messages to a list of errors, specifying the line number, error message, and optional context. This is essential for reporting issues found by custom rules.
const { addError } = require('markdownlint-rule-helpers');
const errors = [];
addError(errors, 1, 'Error message', 'Context');
console.log(errors);
remark-lint is a plugin for remark, a Markdown processor powered by plugins. It provides a flexible and extensible way to lint Markdown files. Compared to markdownlint-rule-helpers, remark-lint offers a broader ecosystem of plugins and integrations, but may require more setup for custom rules.
markdown-it is a Markdown parser with a focus on speed and extensibility. While it is not a linter, it provides a plugin system that can be used to implement custom linting rules. It is more general-purpose compared to markdownlint-rule-helpers, which is specifically designed for linting.
markdownlint is the core linter that markdownlint-rule-helpers is designed to extend. It provides a set of built-in rules for linting Markdown files. While markdownlint-rule-helpers assists in writing custom rules, markdownlint itself is the primary tool for enforcing Markdown standards.
A collection of
markdownlint
helper functions for custom rules
The Markdown linter
markdownlint
offers a variety of built-in validation
rules and supports the
creation of custom rules.
The internal rules share various helper functions; this package exposes those for reuse by custom rules.
Undocumented - This package exports the internal functions as-is. The APIs were not originally meant to be public, are not officially supported, and may change from release to release. There are brief descriptive comments above each function, but no JSDoc annotations. That said, some of what's here will be useful to custom rule authors and may avoid duplicating code.
const { forEachLine, getLineMetadata } = require("markdownlint-rule-helpers");
module.exports = {
"names": [ "every-n-lines" ],
"description": "Rule that reports an error every N lines",
"tags": [ "test" ],
"function": (params, onError) => {
const n = params.config.n || 2;
forEachLine(getLineMetadata(params), (line, lineIndex) => {
const lineNumber = lineIndex + 1;
if ((lineNumber % n) === 0) {
onError({
"lineNumber": lineNumber,
"detail": "Line number " + lineNumber
});
}
});
}
};
See also: markdownlint
built-in rule implementations.
None - The entire body of code is tested to 100% coverage by the core markdownlint
project,
so there are no additional tests here.
0.16.0
FAQs
A collection of markdownlint helper functions for custom rules
The npm package markdownlint-rule-helpers receives a total of 223,634 weekly downloads. As such, markdownlint-rule-helpers popularity was classified as popular.
We found that markdownlint-rule-helpers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.